import { NextRequest, NextResponse } from 'next/server';
import { SDWebUILauncher } from '@/lib/launcher';

const launcher = SDWebUILauncher.getInstance();

export async function POST(request: NextRequest) {
  try {
    await launcher.stopSDWebUI();
    setTimeout(async () => {
      const result = await launcher.startSDWebUI();
      return NextResponse.json(result);
    }, 2000);
    
    return NextResponse.json({
      success: true,
      message: '重启命令已发送'
    });
  } catch (error: any) {
    return NextResponse.json(
      { 
        success: false, 
        error: error.message 
      },
      { status: 500 }
    );
  }
}
